package com.open.source.kafka.delay;

import java.util.LinkedList;

/**
 * @author ZonLen since on 2022/8/9 下午3:12
 */
public interface DelayPartitionStrategy {

  String delayTopic();

  LinkedList<DelayLevel> delayLevels();

  default int maxPartition() {
    return delayLevels().size() - 1;
  }

  default long minDelayTime() {
    return delayLevels().stream().map(DelayLevel::getDelayTime).min(Long::compareTo).orElse(6000L)
        - 1000;
  }

  default long curPartitionDelayTime(int partitionIndex) {
    return delayLevels().get(partitionIndex).getDelayTime();
  }


}
